package geektime.spring.hello.hellospring;

import java.util.HashMap;
import java.util.Map;

import javax.activation.DataSource;

import org.apache.ibatis.logging.Log;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;


//(exclude = {DataSourceAutoConfiguration.class,
//		DataSourceTransactionManagerAutoConfiguration.class,
//		JdbcTemplateAutoConfiguration.class})
//@Slf4j
@SpringBootApplication
@RestController
@MapperScan({"com.baomidou.mybatisplus.samples.quickstart.mapper","geektime.spring.hello.hellospring.dao"})
public class HelloSpringApplication {

	public static void main(String[] args) {
		SpringApplication.run(HelloSpringApplication.class, args);
	}
	@RequestMapping("hello")
	public String hello() {
		return "hello spring";
	}
//	@Bean
//	@ConfigurationProperties("foo.datasource")
//	public DataSourceProperties fooDataSourceProperties() {
//		return new DataSourceProperties();
//	}
//	public DataSource fooDataSource() {
//		DataSourceProperties dataSourceProperties = fooDataSourceProperties();
//		return (DataSource) dataSourceProperties.initializeDataSourceBuilder().build();
//	}
//	public PlatformTransactionManager fooTxManager(DataSource fooDataSource) {
//		return new DataSourceTransactionManager(fooDataSource);
//	}
	/**
	 * 分页插件
	 * @return
	 */
	@Bean
	public PaginationInterceptor paginationInterceptor() {
		PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
		// paginationInterceptor.setLimit(你的最大单页限制数量，默认 500 条，小于 0 如 -1 不受限制);
		return paginationInterceptor;
	}
	@RequestMapping(value = "datableLists")
	@ResponseBody
	public Map<String, String> requestTests() {
		Map<String, String> map = new HashMap<String, String>();
		map.put("1", "1");
		map.put("2", "1");
		map.put("3", "1");
		return map;
	}

}
